import java.util.Scanner;

public class a244_新手訓練_for_if {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int n;
		
		String str1;
		String[] sp;
		
		int a, b, c;
		Long sum;
		
		while(input.hasNext()) {
			n = input.nextInt();
			
			input.nextLine();
			
			for(int i = 0; i < n; i++) {
				str1 = input.nextLine();
				sp = str1.split(" ");
				
				a = Integer.parseInt(sp[0]);
				b = Integer.parseInt(sp[1]);
				c = Integer.parseInt(sp[2]);
				
				sum = (long)0;
				
				if(a == 1)
					sum = (long)b + c;
				else if(a == 2)
					sum = (long)b - c;
				else if(a == 3)
					sum = (long)b * c;
				else if(a == 4)
					sum = (long)b / c;
				
				System.out.println(Long.toString(sum));
			}
		}
	}
	
}